' Use this code at your own risk. I assume no liability for
' the use of this code.
'
' The purpose of XLinkLabel is to have a label control
' that works as a hyperlink.
'
' API Declares
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
' Module level variables
Private nControlHeight As Long
Private nControlWidth As Long
Private bHovering As Boolean
' Property member variables
Private mBackColor As OLE_COLOR
Private mNormTextColor As OLE_COLOR
Private mHoverTextColor As OLE_COLOR
Private mNormUnderline As Boolean
Private mHoverUnderline As Boolean
Private mFont As StdFont
Private mCaption As String
Private mURL As String
Private mEnabled As Boolean
' The property Get/Let/Set stuff if pretty
' self-explanatory, so figure it out :)
Public Property Get BackColor() As OLE_COLOR
BackColor = mBackColor
End Property
Public Property Let BackColor(NewColor As OLE_COLOR)
mBackColor = NewColor
UserControl.BackColor = mBackColor
UserControl_Paint
PropertyChanged "BackColor"
End Property
Public Property Get NormTextColor() As OLE_COLOR
NormTextColor = mNormTextColor
End Property
Public Property Let NormTextColor(NewColor As OLE_COLOR)
mNormTextColor = NewColor
UserControl.ForeColor = NewColor
UserControl_Paint
PropertyChanged "NormTextColor"
End Property
Public Property Get HoverTextColor() As OLE_COLOR
HoverTextColor = mHoverTextColor
End Property
Public Property Let HoverTextColor(NewColor As OLE_COLOR)
mHoverTextColor = NewColor
UserControl_Paint
PropertyChanged "HoverTextColor"
End Property
Public Property Get NormUnderline() As Boolean
NormUnderline = mNormUnderline
End Property
Public Property Let NormUnderline(val As Boolean)
mNormUnderline = val
UserControl.FontUnderline = val
UserControl_Paint
PropertyChanged "NormUnderline"
End Property
Public Property Get HoverUnderline() As Boolean
HoverUnderline = mHoverUnderline
End Property
Public Property Let HoverUnderline(val As Boolean)
mHoverUnderline = val
UserControl_Paint
PropertyChanged "HoverUnderline"
End Property
Public Property Get Font() As StdFont
Set Font = mFont
End Property
Public Property Set Font(NewFont As StdFont)
Set mFont = NewFont
Set UserControl.Font = mFont
UserControl_Paint
PropertyChanged "Font"
End Property
Public Property Get Caption() As String
Caption = mCaption
End Property
Public Property Let Caption(val As String)
mCaption = val
UserControl_Paint
PropertyChanged "Caption"
End Property
Public Property Get URL() As String
URL = mURL
End Property
Public Property Let URL(val As String)
mURL = val
PropertyChanged "URL"
End Property
Public Property Get Enabled() As Boolean
Enabled = mEnabled
End Property
Public Property Let Enabled(val As Boolean)
mEnabled = val
UserControl.Enabled = val
PropertyChanged "Enabled"
End Property
' set up the default values
Private Sub UserControl_InitProperties()
Set Font = Ambient.Font
BackColor = Ambient.BackColor
NormTextColor = Ambient.ForeColor
HoverTextColor = Ambient.ForeColor
URL = "http://www.qtm.net/~davidc" ' got to put my plug in here :)
Enabled = True
Caption = UserControl.Extender.Name
NormUnderline = False
HoverUnderline = True
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
' Read saved properties
On Error Resume Next
Set Font = PropBag.ReadProperty("Font", Ambient.Font)